package com.ruoyi.process.ccs.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.process.ccs.domain.CcsAreatype;
import com.ruoyi.process.ccs.service.ICcsAreatypeService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 *
 * @author Xianlu Tech
 * @date 2020-04-02
 */
@Controller
@RequestMapping("/process/areatype")
public class CcsAreatypeController extends BaseController {
    private String prefix = "process/areatype";

    @Autowired
    private ICcsAreatypeService ccsAreatypeService;

    @RequiresPermissions("process:areatype:view")
    @GetMapping()
    public String areatype() {
        return prefix + "/areatype";
    }

    /**
     * 查询【请填写功能名称】列表
     */
    @RequiresPermissions("process:areatype:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CcsAreatype ccsAreatype) {
        startPage();
        List<CcsAreatype> list = ccsAreatypeService.selectCcsAreatypeList(ccsAreatype);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @RequiresPermissions("process:areatype:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CcsAreatype ccsAreatype) {
        List<CcsAreatype> list = ccsAreatypeService.selectCcsAreatypeList(ccsAreatype);
        ExcelUtil<CcsAreatype> util = new ExcelUtil<CcsAreatype>(CcsAreatype.class);
        return util.exportExcel(list, "areatype");
    }

    /**
     * 新增【请填写功能名称】
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存【请填写功能名称】
     */
    @RequiresPermissions("process:areatype:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(CcsAreatype ccsAreatype) {
        return toAjax(ccsAreatypeService.insertCcsAreatype(ccsAreatype));
    }

    /**
     * 修改【请填写功能名称】
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap) {
        CcsAreatype ccsAreatype = ccsAreatypeService.selectCcsAreatypeById(id);
        mmap.put("ccsAreatype", ccsAreatype);
        return prefix + "/edit";
    }

    /**
     * 修改保存【请填写功能名称】
     */
    @RequiresPermissions("process:areatype:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(CcsAreatype ccsAreatype) {
        return toAjax(ccsAreatypeService.updateCcsAreatype(ccsAreatype));
    }

    /**
     * 删除【请填写功能名称】
     */
    @RequiresPermissions("process:areatype:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(ccsAreatypeService.deleteCcsAreatypeByIds(ids));
    }
}
